package net.wenwuyi.util;

import net.wenwuyi.service.UserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import java.io.PrintStream;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@ContextConfiguration(locations={"classpath:config/applicationContext-*.xml" ,"classpath:config/mybatis-config.xml"})
public class ApplicationSpringContext {
	public ApplicationSpringContext() {
	}

	public static Object getBean(String beanName) {
		return getSpringContext().getBean(beanName);
	}
	public static ApplicationContext getSpringContext() {
		if (ctx == null)
			try {
				ctx = new ClassPathXmlApplicationContext(
						"config/applicationContext-*.xml","classpath:config/mybatis-config.xml");
				System.out
						.println("spring\u5BB9\u5668\u542F\u52A8\u6210\u529F\u3002");
			} catch (Exception e) {
				e.printStackTrace();
				System.out
						.println("spring\u5BB9\u5668\u542F\u52A8\u5931\u8D25\u3002");
			}
		return ctx;
	}

	private static ApplicationContext ctx = null;
}
